import Book.BookList;
import User.Administrator;
import User.Normal;
import User.Users;

import java.util.Scanner;

public class Main {
    public static Users login() {

        System.out.println("*****欢迎来到图书馆*****");
        System.out.println("请输入您的姓名:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        while (true) {
            System.out.println("*********************");
            System.out.println("*****请选择您的身份*****" + "\n" +
                               "*1.图书管理员*2.普通用户*"
            );
            int choice = scanner.nextInt();
            scanner.nextLine();
            if (choice == 2) {
                return new Normal(name);
            }
            if (choice == 1) {
                System.out.println("*****请输入管理员密码*****");
                String password = scanner.nextLine();
                if(password.equals("123456")) {
                    return new Administrator(name);
                }
            }
            System.out.println("*****输入错误,请重新输入*****");
        }
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        Users user = login();
        //login方法的返回值是Users类,用user接收
        while(true){
            int choice = user.menu();
            user.DoIOperation(choice,bookList);
        }
    }
}

